package com.cloud.drore.eboss.supplier.mapper;

import com.cloud.drore.eboos.common.base.MyMapper;
import com.cloud.drore.eboss.supplier.entity.ProductStock;
import com.cloud.drore.eboss.supplier.mapper.provider.ProductStockProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import java.util.List;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/3/12 11:39 <br>
 * @Author: <a href="575842778@qq.com">郑永涛</a>
 */
public interface ProductStockMapper extends MyMapper<ProductStock> {

    @UpdateProvider(type = ProductStockProvider.class, method = "updateProductStockByParam")
    int updateProductStockByParam(ProductStock productStock);

    @SelectProvider(type = ProductStockProvider.class, method = "findProductStockByParam")
    ProductStock findProductStockByParam(ProductStock productStock);

    @Select("select distributor_id from eboos_distributor_product_association where main_id = '${commonProductId}' ")
    List<Long> selectDistributorIdByCommonProductId(@Param("commonProductId") Long commonProductId);

    @Select("select count(1) from  eboos_product_stock where is_deleted ='0' and common_product_id = '${commonProductId}' ")
    int countByCommonProductId(@Param("commonProductId") Long commonProductId);

}